package com.xexun.gpstracker.util;

import java.util.LinkedHashMap;

/**
 * Created by HH
 * Date: 2015/11/25 0025
 * Time: 下午 3:01
 */
public class CommCache<K, V> extends LinkedHashMap<K, V> {
    private int MAX_SIZE;

    public CommCache(boolean isLRU) {
        super((int) Math.ceil(8 / 0.75) + 1, 0.75f, isLRU);
        MAX_SIZE = 8;
    }

    public CommCache(int cacheSize, boolean isLRU) {
        super((int) Math.ceil(cacheSize / 0.75) + 1, 0.75f, isLRU);
        MAX_SIZE = cacheSize;
    }

    @Override
    protected boolean removeEldestEntry(Entry<K, V> eldest) {
        return size() > MAX_SIZE;
    }
}
